#!/usr/bin/python
# -*- coding: utf-8 -*-

# 最大公约数 greatest common divisor
def gcd(x,y):
    # 根据大小给x,y重新赋值
    (x,y) = (y,x) if x > y else (x,y)
    # range(start,end,step) step是指每一次运算 -1就是减1 1就是加1 默认是1
    for factor in range(x,0,-1):
        if x % factor == 0 and y % factor == 0:
            return factor

# 最小公倍数 lowest common multiple
def lcm(x,y):
    return x * y // gcd(x,y)

# 判断是否是回文数
def is_palindrome(num):
    temp = num
    total = 0
    # 将temp反过来
    while temp > 0:
        total = total * 10 + temp % 10
        temp //= 10
    return total == num
# print(is_palindrome(12))
# print(is_palindrome(12321))

# 判断是否是素数
def is_prime(num):
    for factor in range(2,num):
        if num % factor == 0:
            return False
    return True if num != 1 else False
# print(is_prime(3))
# print(is_prime(4))

# 判断是不是回文素数
def is_palindromeAndPrime(num):
    return is_prime(num) and is_prime(num)
# print(is_palindromeAndPrime(12))
# print(is_palindromeAndPrime(3))

